package 程序员面试金典;

import org.junit.Test;

public class 整数转换 {

    public int convertInteger(int A, int B) {
         int sum=0;
        int C = A ^ B;
        while (C!=0){
             if ((C&1)==1)
                 sum++;
             C>>>=1;
         }
         return sum;
    }
    @Test
    public void test(){
        System.out.println(Integer.toBinaryString(29));
        System.out.println(Integer.toBinaryString(15));
        System.out.println(convertInteger(29, 15));
    }
}
